home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / refex / ex21.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  837 b   |  41 lines

  1. Program Example21;
  2.  
  3. { Program to demonstrate the Exit function. }
  4.  
  5. Procedure DoAnExit (Yes : Boolean);
  6.  
  7. { This procedure demonstrates the normal Exit }
  8.  
  9. begin
  10.   Writeln ('Hello from DoAnExit !');
  11.   If Yes then
  12.     begin
  13.     Writeln ('Bailing out early.');
  14.     exit;
  15.     end;
  16.   Writeln ('Continuing to the end.');
  17. end;
  18.  
  19. Function Positive (Which : Integer) : Boolean;
  20.  
  21. { This function demonstrates the extra FPC feature of Exit : 
  22.   You can specify a return value for the function }
  23.  
  24. begin
  25.   if Which>0 then
  26.     exit (True)
  27.   else
  28.     exit (False);
  29. end;   
  30.  
  31. begin
  32.   { This call will go to the end }
  33.   DoAnExit (False);
  34.   { This call will bail out early }
  35.   DoAnExit (True);
  36.   if Positive (-1) then 
  37.     Writeln ('The compiler is nuts, -1 is not positive.')
  38.   else
  39.     Writeln ('The compiler is not so bad, -1 seems to be negative.');
  40. end.
  41.